const addZero = (num) => {
  if (num < 10) {
    return '0' + num;
  } else {
    return num
  }
}

/**
 * @type {import('@/types/global').setStatisticsDefautTime}
 */
const setStatisticsDefautTime = (type) => {
  const date = new Date()
  const year = date.getFullYear()
  const month = addZero((date.getMonth() + 1))
  const day = addZero(date.getDate())



  if (type == 'day') {
    /**本月第一日 */
    const thisMonthFirstDay = `${year}-${month}-01`
    /**今日 */
    const today = `${year}-${month}-${day}`
    return [thisMonthFirstDay, today]
  }

  if (type == 'month') {
    const defaultMonth = `${year}-${month}-01`
    return [defaultMonth, defaultMonth]
  }

}

export default setStatisticsDefautTime
